Release 10.1A: OpenEdge Development:
ProDataSets
ROW-STATE attribute
There is a
ROW-STATEattribute on the temp-table buffer in both the after-table and the before-table to allow you to determine how, if at all, each record has been changed.ROW-STATEis an integer value representing one of these constants, which you can and should use to identify the meaning of theROW-STATE:Note that these are unquoted literals that correspond to integer values, much like the values
NO-LOCK,SHARE-LOCK, andEXCLUSIVE-LOCKforLOCK-MODE. You use the literals in 4GL logic, in statements such as this:
If you display the
ROW-STATE, it is displayed as an integer.Each record in the after-table that has been modified or added has an internal pointer to its counterpart in the before-table. These after-table records have a
ROW-STATEvalue ofROW-MODIFIEDorROW-CREATED, depending on whether the row has been added to the temp-table sinceTRACKING-CHANGESwas set to true. Deleted records do not appear in the after-table, because it reflects the current state of the data. Records in the after-table that have not been added or changed have aROW-STATEofROW-UNMODIFIED. These records have no counterpart in the before-table.Every record in the before-table has a nonzero
ROW-STATEbecause every record is the before-image for a deleted, created, or modified record. Records in the before-table can have aROW-STATEequal to one of these values:
ROW-DELETED— A deleted row in the before-table holds the original field values of the record at the timeTRACKING-CHANGESwas set to true. It has no counterpart in the after-table. A record is moved from the after-table to the before-table when it is deleted. Thus, the only way to locate deleted records is in the before-table. If a record is modified and then later deleted before changes are processed, then its state isROW-DELETEDand there is no record of the changes made before that.ROW-MODIFIED— A modified row in the before-table holds the field values of the record at the time thatTRACKING-CHANGESwas last set to true. The row is copied from the after-table when it is first changed. No intermediate changes between the “original” values and the latest values are saved anywhere.ROW-CREATED— A newly created row is created in the before-table at the same time that the equivalent record is created in the after-table. The before-table row for a created row does not hold any meaningful field values. It serves merely as a placeholder for the row so that you can identify created rows along with modified and deleted ones by looking at the before-table. The field values in the after-table can then be changed as the record is edited, just as for changed rows. TheROW-STATEremainsROW-CREATEDuntil changes to the table have been processed, regardless of how many times field values have been modified in the meantime.Records in the after-table can have a
ROW-STATEofROW-UNMODIFIED,ROW-CREATED, orROW-MODIFIED. This means that new records and changed records can be tracked through either table. However, because deleted records are removed from the after-table, they can be tracked only through the before-table. In general, you should process changes through the before-table for this reason.ROW-STATE function
It is not possible to check the value of an attribute such as
ROW-STATEin a where-clause. For this reason, there is also aROW-STATEfunction that can be referenced in a where-clause to let you filter ProDataSet temp-table rows by theirROW-STATE. TheROW-STATEfunction takes a buffer name as its argument and returns the same integer value as theROW-STATEattribute. Ordinarily you should apply the function to a before-table buffer, but you can also use the after-table buffer name as well with the same effect. If there is no record in the buffer passed, or it is not a before-table, or is not an after-table that has a before-table associated with it, then theROW-STATEvalue returned is“?”. An error is not raised.The function lets you construct a
where-clause, such as in the following example:
Special restrictions on TRACKING-CHANGES
There are some general restrictions on the use of
TRACKING-CHANGESthat mostly exist as sanity checks to prevent people from doing unexpected things and expecting something useful to happen:
- If you try to do a
FILLor anEMPTY-DATASETwhileTRACKING-CHANGESis true, Progress raises an error.- If you pass a ProDataSet remotely or locally by value and
TRACKING-CHANGESis true for the ProDataSet or any of its tables, the before- and after-tables are passed in their current state, but the value of theTRACKING-CHANGESattribute is not passed, that is, it is not automatically set toTRUEon the receiving side.Normally, if you set
TRACKING-CHANGEStoTRUE, make changes, and then pass the ProDataSet as a parameter, the receiver processes the changes without making further changes that should be recorded in the before-table. If the receiving procedure wants to make further changes, it must setTRACKING-CHANGESto true after receiving the ProDataSet parameter.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |